/**
 * 
 */
var params={size:12};
var Mr;
$(function() {
	//Mr = [[${Mr}]]; 
	loadDataPageIetm("/zbdzllN", "srcoll-documentation", "lists",params);
	
});
//分页查询，对结果的处理
function dataKk(data, me) {
	data=data.rows;
	var result = '';
	var arrLen = data.length;
	if (arrLen > 0) {
		for (var i = 0; i < arrLen; i++) {
			
			result +='<li onclick="clickli(this)" rowId="'+data[i].id+'" title="'+data[i].taskDesc+'" ownType="rows"><div class="spare-new clearfix"><div class="zbdzll-wxjhl">编号：'+data[i].taskCode+'</div>'
					+'<div class="zbdzll-wxjhl">项目名称：'+data[i].taskDesc+'</div>'
					+'<div class="zbdzll-wxjhl">项目类型：'+data[i].maintPlanningType+'</div></div>'
					+'<div class="spare-new clearfix"> <div class="zbdzll-wxjhl">维护部位号：'+data[i].areaNumber+'</div>' 
					+'<div class="zbdzll-wxjhl">维护部位名称：'+data[i].areaName+'</div>'
					+'<div class="zbdzll-wxjhl">间隔期：'+data[i].limitCond+'</div></div>'
					+'<div class="spare-new clearfix"><div class="zbdzll-wxjhm">引用列表：</div><div class="zbdzll-wxjhr"><a dmId="'+data[i].dmodelId+'" projectId="'+data[i].projectId+'" onclick="dw(this)">'+data[i].refsName+'</a></div></div>'
					+'<div class="spare-new clearfix"><div class="zbdzll-wxjhm">备注：</div><div class="zbdzll-wxjhr">'+data[i].remarks+'</div></div><div class="documentation-check"></div></li>';
		}
	} else {
		me.lock();
		me.noData();
	}
	return result;
}
/*选中某一条数据 */
function clickli(e){
	 /*装备电子履历*/
	 $(".zbdzll-wxjh li").removeClass("active");
	 $(e).addClass("active");
	 Mr.planId=$(e).attr("rowId");
	 Mr.planName=$(e).attr("title");
	 $.get("/zbdzll-rwBack", Mr,function(result){
			$("body").html(result);
		  });
}
/*查询 */
function searchCon(value){
	$('#lists').html("");
	params={size:12,limitCond:value};
	loadDataPageIetm("/zbdzllN", "srcoll-documentation", "lists",params);
}

function loadDataPageIetm(path, classId1, classId, params) {
	$(".dropload-down").remove();
    // 页数
    var page = 0;
    // 每页展示
    var dropload = $('#' + classId1).dropload({
        domDown: {
            domClass: 'dropload-down',
            domRefresh: '<div class="dropload-refresh"></div>',
            domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData: '<div class="dropload-noData"></div>'
        },
        loadDownFn: function(me) {
            //page++;
        	params.page=page;
            $.ajax({
                type: 'post',
                url: path,
                data: params,
                dataType: 'json',
                success: function(data) {
                    var result = dataKk(data, me);
                    $('#' + classId).append(result);
                    if("/ietm/user-helpN"===path){
                    	helpTextSearch();
                    }
                    window.oncontextmenu = function() {
                        return false;
                    }
                    $(".documentation a").on('contextmenu',
                    function() {
                        // pad长按选中，pc右键选中
                        $(this).children('li:eq(0)').addClass("active");
                        $('.spare-ara-ar').find('a[hid="Y"]').show();
                    }).click(function(e) {
                        // pad单击选中状态取消选择，未选择状态跳转查看
                        if ($(this).children('li:eq(0)').attr('class').indexOf('active') > -1) {
                            $(this).children('li:eq(0)').removeClass("active");
                            if ($('.spare-ara').find('li[class="active"]').length === 0) {
                                $('.spare-ara-ar').find('a[hid="Y"]').hide();
                            }
                            e.preventDefault();
                        }
                    });
                    // 全选，取消选择
                    $('.spare-qx').off('click').on('click',
                            function(e) {
                                if ($(this).attr('sel') == 'Y') {
                                    $(this).html('取 消').attr('sel', 'N');
                                    $('.documentation li').addClass('active');
                                } else {
                               
                                    $(this).html('全 选').attr('sel', 'Y');
                                    $('.documentation li').removeClass('active');
                                    $('.spare-ara-ar').find('a[hid="Y"]').toggle();
                                }
                                e.preventDefault();
                            });
                    me.resetload();
                },
                error: function(xhr, type) {
                    alert('Ajax error!');
                    // 即使加载出错，也得重置
                    dropload.resetload();
                }
            });
            page++;
        }
    });
}
